<template>
  <div style="height:240px;overflow:hidden; margin-top: 5px">
    <el-card shadow="never" class="box-card">
      <div slot="header" class="clearfix">
        <span>传达学习</span>
        <div style="float: right; padding: 3px 0" type="text">
          <a @click="showDetail()">查看全部 &gt;</a>
        </div>
      </div>
      <el-table :data="convey" class="left_menu_side" :show-header="false">
        <el-table-column prop="subject" :show-overflow-tooltip="true" label="名称">
          <template slot-scope="scope">
            <a @click="showSingle(scope.row)">{{scope.row.subject}}</a>
          </template>
        </el-table-column>
        <el-table-column prop="publisher" :show-overflow-tooltip="true" label="发布人" width="70"></el-table-column>
        <el-table-column prop="publishtime" :show-overflow-tooltip="true" label="接收时间" width="148"></el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script type="text/javascript">
  import { ACCESS_TOKEN, ACCESS_TOKEN_IP } from '@/store/mutation-types'
  import Vue from 'vue'
  import { handleUrl, openIFrame } from '@/utils/util'

  export default {
    data() {
      return {
        convey: []
      }
    },
    mounted() {
      this.getAdminList()
    },
    methods: {
      showSingle(record) {
        let baseUrl = process.env.VUE_APP_ADD_HTTP
        let ticket = Vue.ls.get(ACCESS_TOKEN)
        let docId = record.docid
        let url = baseUrl + '/Modules/PublicDocument/view/view.htm?LoginMethod=ssologin&ticket=' +
          ticket + '&id=' + docId + ''
        openIFrame(record.docid, '/Convey/' + record.docid, record.subject, url)
        this.$router.push({ name: record.docid })
      },
      showDetail() {
        let ticket = Vue.ls.get(ACCESS_TOKEN);
        let ReturnUrl = encodeURIComponent('/Modules/PublicDocument/index.htm?request=ChuanDaXueXiList&request_type=2#');
        let baseUrl = process.env.VUE_APP_ADD_HTTP;
        let UserIP = "&UserIP="+ Vue.ls.get(ACCESS_TOKEN_IP);
        let url = baseUrl + "/login.xip?LoginMethod=ssologin&Ticket=" + ticket + UserIP + "&ReturnUrl=" + ReturnUrl + "";
        openIFrame("ConveyList",'/ConveyList',"传达学习列表",url)
        this.$router.push({ name: 'ConveyList' })
      },
      getAdminList() {
        let that = this
        let params = {
          serviceName: 'Xinfo.Bus.BL.Service.EgovPlatform.PortalLet.PublicDocmentPortalLetService,Xinfo.Bus.BL.Service',
          guid: 'rcgz_cdxx',
          getCount: false,
          intTypeId: 56,
          strBizType: '',
          TaskType: 1
        }
        this.getRequest('/PortalLet/GetPortalLetData', params)
          .then(res => {
            if (res) {
              res.data.forEach((row, index) => {
                if (index <= 5) {
                  that.convey.push(row)
                }
              })
            }
          })
      }
    }
  }
</script>